package com.atguigu.sparkcore.day02.kv

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 * Author atguigu
 * Date 2020/10/28 16:45
 */
object CogroupDemo {
    def main(args: Array[String]): Unit = {
        val conf: SparkConf = new SparkConf().setAppName("JoinDemo").setMaster("local[2]")
        val sc: SparkContext = new SparkContext(conf)
        val list1 = List(30, 50, 70, 6, 10, 20, 30)/*.map((_, "a"))*/
        val list2 = List(30, 70, 60, 1, 2, 30)/*.map((_, "b"))*/
        val rdd1 = sc.parallelize(list1, 2)
        val rdd2 = sc.parallelize(list2, 2)
    
        //val rdd3: RDD[(Int, (Iterable[String], Iterable[String]))] = rdd1.cogroup(rdd2)
    
        val rdd3: RDD[(Int, Int)] = rdd1.cartesian(rdd2)
        
        rdd3.collect.foreach(println)
    }
}
